package com.ewanghuiju.app.presenter.home;

import com.ewanghuiju.app.base.RxPresenter;
import com.ewanghuiju.app.base.contract.home.OtherContract;
import com.ewanghuiju.app.model.DataManager;
import com.ewanghuiju.app.model.bean.response.PintuanClassifyResponBean;
import com.ewanghuiju.app.model.http.response.Optional;
import com.ewanghuiju.app.util.RxUtil;
import com.ewanghuiju.app.widget.CommonSubscriber;

import java.util.List;

import javax.inject.Inject;

/**
 * @author sj  qq:751943509
 * @class 除了精选
 * @time 2020/2/16
 */
public class OtherPresenter extends RxPresenter<OtherContract.View> implements OtherContract.Presenter {

    private DataManager mDataManager;

    @Inject
    public OtherPresenter(DataManager mDataManager) {
        this.mDataManager = mDataManager;
    }

    @Override
    public void getData() {

    }

    @Override
    public void getPticatesAll() {

        addSubscribe(mDataManager.getPticateslist()
                        .compose(RxUtil.rxSchedulerHelper())
                        .compose(RxUtil.handleMyResultCannull())
                        .subscribeWith(new CommonSubscriber<Optional<List<PintuanClassifyResponBean>>>(mView) {
                            @Override
                            public void onNext(Optional<List<PintuanClassifyResponBean>> optional) {
                                mView.showPticatesAll(optional.getIncludeNull());
                            }

                            @Override
                            public void onError(Throwable e) {
                                super.onError(e);
//                        if (e instanceof ApiException) {
//                        } else {
//                        }
                            }
                        })
        );

    }
}
